package com.wnn.demo.model.system.mapper;

import com.wnn.demo.domain.Role;
import com.wnn.demo.domain.User;
import com.wnn.demo.domain.UserAndRole;
import com.wnn.demo.utils.IBaseMapper;
import com.wnn.demo.vo.UserVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.*;


/**
* Created by Mybatis Generator on 2019/08/31
*/
public interface UserMapper extends IBaseMapper<User> {

    /**
     * 根据用户id链表查询了用户的角色和权限
     * @param id
     *@return user
     */
    List< Map<String,Object> > findUserById(@Param("id") String id);


    /**
     * 查询全部用户的信息，链表查询了角色信息
     * @return user和role
     */
    List<UserVo> findUserList();

    /**
     * 根据用户Ids批量查询
     * @param ids
     * @return
     */
    List<User> selectUserListByIds(@Param("ids") String ids );

    /**
     * 按用户名查找用户
     * @param username
     * @return
     */
    User findUserByName(@Param("username") String username);

    /**
     * 批量删除用户
     * @param users
     * @return int
     */
    int batchDeleteUserByList(@Param("users") List< User> users);

    int batchInsertUserAndRoleList(@Param("userAndRoleList") List< UserAndRole > userAndRoleList);

    int batchDeleteUserAndRoleList(@Param("userId") String userId, @Param("ids") List<String>  ids);

    /**
     * 根据用户id找到中间表user_role包含用户id的所有信息
     * @param userId
     * @return
     */
    List<UserAndRole> selectUserAndRoleListByUserId(@Param("userId") String userId);

    /**
     * 按用户名查找用户
     * @param userName
     * @return User+Role 信息
     */
    User findUserHaveRolesByUserName(@Param("userName") String userName);

    int insertInto(User user);


    int addPermission(User user);

    int registerCheck(User user);
}